package com.shumi.rbac.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.shumi.rbac.model.User;
import com.shumi.rbac.model.Khyhxx;
import com.shumi.rbac.service.SystemService;
@RestController
@RequestMapping(value="/khdb")
public class KhdbController {
	
	@Autowired
	SystemService systemService;
	
	@RequestMapping(value="/wdbUpdate")	
	@ResponseBody
	public Map wdbUpdate(String id,HttpSession session,Khyhxx khyhxx){
	Map map=new HashMap();
	Object object=session.getAttribute("user");
	User user=(User)object;
	String userId=user.getUserId();
	systemService.updateWdbyhxx(khyhxx,userId);
	map.put("data", "success");
	map.put("status", "200");
		return map;	
	}
	
	@RequestMapping(value="/wdbdetail")	
	@ResponseBody
	public Map wdbdetail(String id){
	Map map=new HashMap();
	map.put("data", "success");
	map.put("yhdata", systemService.wdbdetail(id));
	map.put("status", "200");
		return map;	
	}
	
	@RequestMapping(value="/wdbFindAll")	
	@ResponseBody
	public Map wdbFindAll(HttpSession session){
	Map map=new HashMap();
	Object object =session.getAttribute("user");
	User user =(User)object;
	String userId=user.getUserId();
	map.put("data", "success");
	map.put("yhdata", systemService.wdbFindAll(userId));
	map.put("status", "200");
		return map;	
	}
	
	
	@RequestMapping(value="/ydbdetail")	
	@ResponseBody
	public Map ydbdetail(String id){
	Map map=new HashMap();
	map.put("data", "success");
	map.put("yhdata", systemService.ydbdetail(id));
	map.put("status", "200");
		return map;	
	}
	
	@RequestMapping(value="/ydbFindAll")	
	@ResponseBody
	public Map ydbFindAll(HttpSession session){
	Map map=new HashMap();
	Object object =session.getAttribute("user");
	User user =(User)object;
	String userId=user.getUserId();
	map.put("data", "success");
	map.put("yhdata", systemService.ydbFindAll(userId));
	map.put("status", "200");
		return map;	
	}

}
